package com.bw.router

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Interceptor
import com.alibaba.android.arouter.facade.callback.InterceptorCallback
import com.alibaba.android.arouter.facade.template.IInterceptor
import com.bw.base.constants.ApiConst
import com.bw.base.constants.RoutePath
import com.tencent.mmkv.MMKV


@Interceptor(priority = 6, name = "路由参数拦截器")
class RouterParamsInterceptor:IInterceptor {
    private lateinit var mContext: Context

    override fun init(context: Context?) {
        if (context != null) {
            mContext = context
        }
    }

    override fun process(postcard: Postcard?, callback: InterceptorCallback?) {
        val accessId = MMKV.defaultMMKV().decodeString(ApiConst.PARAM_ACCESS_ID, "park_accessId")
        if(!accessId.isNullOrEmpty()){
            postcard?.withString(ApiConst.PARAM_ACCESS_ID,accessId)

        }
        callback?.onContinue(postcard)
    }

}